package phenix.com.phenixdemo.control;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.widget.Toast;

import phenix.com.phenixdemo.ActivityMain;

/**
 * Created by zhouphenix on 2016-3-13.
 */
public class WidgetClickHandlerService extends Service {
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Toast.makeText(this,"remoteView..."+intent.getStringExtra("clicked_item")+"--"+intent.getIntExtra("clicked_position",-1), Toast.LENGTH_SHORT).show();
        if (null != intent){
            Intent i = new Intent(this,ActivityMain.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.putExtra("clicked_position",intent.getIntExtra("clicked_position",-1));
            startActivity(i);
        }

        return super.onStartCommand(intent, flags, startId);
    }
}
